<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui, viewport-fit=cover">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>My App</title>
    <link rel="stylesheet" href="../../packages/core/css/framework7.min.css">
  </head>
  <body>
    <div id="app">
      <div class="view view-main">
        <div class="page">
          <div class="navbar">
            <div class="navbar-inner">
              <div class="left"><a class="link popover-open" href="#" data-popover=".popover-about">About</a></div>
              <div class="title">Popover</div>
              <div class="right"><a class="link popover-open" href="#" data-popover=".popover-links">Links</a></div>
            </div>
          </div>
          <div class="page-content">
            <div class="block">
              <p><a class="link popover-open" href="#" data-popover=".popover-about">Open About Popover</a></p>
              <p><a class="link popover-open" href="#" data-popover=".popover-links">Open Links Popover</a></p>
              <p><a class="link dynamic-popover" href="#">Create Dynamic Popover</a></p>
            </div>
          </div>
        </div>
      </div>
      <style>
        .popover {
          width:200px;
        }
        
      </style>
      <div class="popover popover-about">
        <div class="popover-inner">
          <div class="block">
            <p>About</p>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque ac diam ac quam euismod porta vel a nunc. Quisque sodales scelerisque est, at porta justo cursus ac.</p>
          </div>
        </div>
      </div>
      <div class="popover popover-links">
        <div class="popover-inner">
          <div class="list">
            <ul>
              <li><a class="list-button item-link" href="#">Link 1</a></li>
              <li><a class="list-button item-link" href="#">Link 2</a></li>
              <li><a class="list-button item-link" href="#">Link 3</a></li>
              <li><a class="list-button item-link" href="#">Link 4</a></li>
            </ul>
          </div>
        </div>
      </div>
    </div>
    <script type="text/javascript" src="../../packages/core/js/framework7.min.js"></script>
    <script>
      var theme = 'ios';
      if (location.href.indexOf('theme=md') >= 0) theme = 'md';
      var plugin = {
        params: {
          theme: theme,
          root: '#app',
        }
      };
      if (Framework7.use) Framework7.use(plugin);
      else if (Framework7.Class && Framework7.Class.use) Framework7.Class.use(plugin);
      
    </script>
    <script>
      var app = new Framework7();
      
      var $$ = Dom7;
      
      // DOM events for About popover
      $$('.popover-about').on('popover:open', function (e, popover) {
        console.log('About popover open');
      });
      $$('.popover-about').on('popover:opened', function (e, popover) {
        console.log('About popover opened');
      });
      
      // Create dynamic Popover
      var dynamicPopover = app.popover.create({
        targetEl: 'a.dynamic-popover',
        content: '<div class="popover">'+
                    '<div class="popover-inner">'+
                      '<div class="block">'+
                        '<p>Popover created dynamically.</p>'+
                        '<p><a href="#" class="link popover-close">Close me</a></p>'+
                      '</div>'+
                    '</div>'+
                  '</div>',
        // Events
        on: {
          open: function (popover) {
            console.log('Popover open');
          },
          opened: function (popover) {
            console.log('Popover opened');
          },
        }
      });
      // Events also can be assigned on instance later
      dynamicPopover.on('close', function (popover) {
        console.log('Popover close');
      });
      dynamicPopover.on('closed', function (popover) {
        console.log('Popover closed');
      });
      
      // Open dynamic popover
      $$('.dynamic-popover').on('click', function () {
        dynamicPopover.open();
      });
    </script>
  </body>
</html>